package iblink.util;

import packutil.exception.InvalidArgumentException;

public class Constants {

	public static enum SecType {
		STOCK("STK"), OPTION("OPT");

		private String ibString;

		private SecType(String ibString) {
			this.ibString = ibString;
		}

		public String getIbString() {
			return ibString;
		}
	}

	public static enum DataType {
		TRADES, MIDPOINT, BID, ASK, BID_ASK, HISTORICAL_VOLATILITY, OPTION_IMPLIED_VOLATILITY, OPTION_VOLUME, OPTION_OPEN_INTEREST;

		public String getIbString() {
			return toString();
		}
	}

	public static enum Duration {
		ONE_DAY("1 D");

		private String ibString;

		private Duration(String ibString) {
			this.ibString = ibString;
		}

		public String getIbString() {
			return ibString;
		}
	}

	public static enum BarSize {
		ONE_SEC("1 sec"), FIVE_SECS("5 secs"), FIFTEEN_SECS("15 secs"), THIRTY_SECS(
				"30 secs"), ONE_MIN("1 min"), TWO_MINS("2 mins"), THREE_MINS(
				"3 mins"), FIVE_MINS("5 mins"), FIFTEEN_MINS("15 mins"), THIRTY_MINS(
				"30 mins"), ONE_HOUR("1 hour"), ONE_DAY("1 day");

		private String ibString;

		private BarSize(String ibString) {
			this.ibString = ibString;
		}

		public String getIbString() {
			return ibString;
		}

		public static BarSize parseIbString(String s) {

			if ("1 min".equals(s)) {
				return ONE_MIN;
			}

			throw new InvalidArgumentException("Can not parse string [" + s
					+ "] into " + BarSize.class.getSimpleName());
		}

	}

	public static enum Right {
		PUT("P"), CALL("C");

		private String ibString;

		private Right(String ibString) {
			this.ibString = ibString;
		}

		public String getIbString() {
			return ibString;
		}

		public static Right parseIbString(String s) {

			if ("C".equals(s)) {
				return CALL;
			}
			if ("P".equals(s)) {
				return PUT;
			}

			throw new InvalidArgumentException("Can not parse string [" + s
					+ "] into " + Right.class.getSimpleName());
		}
	}

}
